<template>
  <div id="changedialog">
    <commonformdialog
      :isshowDialogs="isshowDialog"
      :dialogTitle="dialogTitle"
      @closetextDialog="closetextDialog"
      @confirmbtn="confirmbtn"
      @rejected="rejected"
      :isshowFooter="false"
      :isshowFooterBh="isshowFooterBh"

    >
      <div class="innerLoding">
        <el-row>
          <el-form
            ref="xlcform"
            size="small"
            :rules="rules"
            :model="formData"
            label-width="120px"
          >
            <el-col :span="24">
              <h3 class="titleTips">
                平台信息：<span class="look">{{ formData.statusText }}</span>
              </h3>
            </el-col>
            <el-col :span="24">
              <el-form-item label="LOGO :" prop="logo">
                <el-image
                  style="width: 100px; height: 100px"
                  :src="formData.logo"
                  :preview-src-list="[formData.logo]"
                  :zIndex="9999"
                >
                </el-image>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="平台名称 :" prop="title">
				<span>{{formData.title}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="平台类型 :" prop="type">
                <span v-if="formData.type==1">微信小程序</span>
                <span v-if="formData.type==2">微信公众号</span>
                <span v-if="formData.type==3">H5</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否联营 :" prop="is_pool">
                <span>{{formData.is_pool==1?'是':'否'}}</span>
              </el-form-item>
            </el-col>
           
            <el-col :span="12">
              <el-form-item label="APPCODE :" prop="app_code">
               <span>{{formData.app_code}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="APPKEY :" prop="app_key">
               <span>{{formData.app_key}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="APPID :" prop="app_id">
               <span>{{formData.app_id}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="SECRET :" prop="app_secret">
                <span>{{formData.app_secret}}</span>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="商户ID :" prop="mch_id">
                  <span>{{formData.mch_id}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="商户KEY :" prop="mch_key">
                 <span>{{formData.mch_key}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="驾校名称 :" prop="schoolTitle">
                <span>{{ formData.schoolTitle }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="公司全称 :" prop="company">
                <span>{{ formData.company }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="驾校联系人 :" prop="leaderMan">
                <span>{{ formData.leaderMan }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="驾校联系电话 :" prop="leaderTel">
                <span>{{ formData.leaderTel }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="城市 :" prop="city">
                <span>{{ formData.city }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="申请时间 :" prop="create_time">
                <span>{{ formData.create_time }}</span>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      <toExamine
        :isshowDialogE="isshowDialogE"
        :status="status"
        :id="id"
        @closedialogE="closeDialogE"
        @confirmbtnE="confirmbtnE"
      ></toExamine>
    </commonformdialog>
  </div>
</template>

<script type="text/javascript">
//引入弹窗
import commonformdialog from "@/components/commondialog/commondialog";
import uploadimg from "@/components/uploadimg/uploadimg";
import toExamine from "./toExamine";
import { platformApproval } from "@/api/institutional";
export default {
  data() {
    return {
      formData: {
        type:1,
        is_pool:0
      },
      rules: {
        // logo: [{ required: true, message: "请上传封面图", trigger: "blur" }],
        // title: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
        // mch_id: [{ required: true, message: "请输入商户ID", trigger: "blur" }],
        // app_id: [{ required: true, message: "请输入appID", trigger: "blur" }],
        // app_secret: [{ required: true, message: "请输入secretID", trigger: "blur" }],
        // mch_key: [
        //   { required: true, message: "请输入商户KEY", trigger: "blur" },
        // ],
        // type: [
        //   { required: true, message: "请选择平台类型", trigger: "blur" },
        // ],
        // is_pool: [
        //   { required: true, message: "请选择是否联营", trigger: "blur" },
        // ],
      },
      isshowFooterBh: false,
      isshowDialogE: false,
      isdisable: true,
      status: null,
      id: null,
      mapData: {},
    };
  },
  props: {
    //是否显示弹窗
    isshowDialog: {
      type: Boolean,
      default: false,
      required: true,
    },
    //表单的名字
    dialogTitle: {
      type: String,
      default: "",
      required: true,
    },
    //是编辑还是新增
    formType: {
      type: Number,
      default: 0,
    },
    dialogdata: {
      type: Object,
    },
  },
  components: {
    commonformdialog,
    toExamine,
    uploadimg,
  },
  methods: {
    //删除图片
    picturedel() {
      this.formData.logo = "";
    },
    //上传图片成功
    pictureok(val) {
      console.log(val);
      this.formData.logo = val.url;
    },
    closetextDialog() {
      this.$emit("closedialog");
    },
    //关闭审核弹框
    closeDialogE() {
      this.isshowDialogE = false;
    },
    //提交审核
    confirmbtnE() {
      this.isshowDialogE = false;
      //通知父级关闭弹框
      console.log("审核提交");
      this.$emit("confirm");
    },
    //驳回
    rejected() {
      this.status = 2;
      this.id = this.formData.id;
      this.isshowDialogE = true;
    },
    //通过
    async confirmbtn() {
      console.log(this.formData);
      this.$refs["xlcform"].validate(async (valid) => {
        if (!valid) return;
        //TODO 提交表单
        // let { id, logo, title, type, mch_id, mch_key, app_id, is_pool,app_secret } =
        //   this.formData;
        let params ={}
        params.status = 1;
        params.id = this.formData.id;
        let data = await platformApproval(params);
        if (data.code == "0000") {
          this.$message({
            type: "success",
            message: data.msg,
          });
        }
        this.$emit("confirm");
      });
    },
  },
  watch: {
    isshowDialog: function (val) {
      if (!val) {
        this.$refs["xlcform"].resetFields();
      }
    },
    dialogdata: function (val) {
      if (val) {
        this.$nextTick(() => {
          this.formData = val;
          if(this.formType!=0){
            this.formData.type=1
          }
        });
      }
    },

    formType: function (val) {
      if (val === 0) {
        this.isshowFooterBh = false;
      } else {
        this.isshowFooterBh = true;
      }
    },
  },
  created() {},
};
</script>

<style lang="scss" scoped>

.mapBox {
  position: relative;
  height: 500px;
}
.textItem {
  h3 {
    color: red;
    margin-bottom: 10px;
  }
  .borderTitle {
    font-weight: bold;
    font-size: 15px;
  }
}
</style>
